using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Entities;
using Utility;


public partial class Admin_SanPham_CapNhatDanhMuc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbDanhMuc  danhmuc = tbDanhMucBUS.GetByID(id);
            if (danhmuc != null)
            {
                txt_MaDanhMuc.Text = id.ToString();
                txt_TenDanhMuc.Text = danhmuc.TenDanhMuc;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/SanPham/DanhSachDanhMuc.aspx");
        }

    }
    protected void btn_luu_Click(object sender, EventArgs e)
    {
        try
        {
            tbDanhMuc danhmuc = new tbDanhMuc();
            danhmuc.MaDM = int.Parse(txt_MaDanhMuc.Text);
            danhmuc.TenDanhMuc = txt_TenDanhMuc.Text;
            tbDanhMucBUS.UpDate(danhmuc);
        }
        catch
        {
            Response.Redirect("~/Admin/SanPham/DanhSachDanhMuc.aspx");
        }
        Response.Redirect("~/Admin/SanPham/DanhSachDanhMuc.aspx");

    }
}
